<template>
  <div>
    <!-- 页面基础模板 -->
    <base-header-footer
      :isShowContentTitle="false"
      :isShowBreadCrumb="false"
      :isShowArchived="true"
    >
      <!-- isShowTitle : 布尔值，是否显示当前页面标题组件-->
      <!-- isShowBreadCrumb : 布尔值，是否显示当前页面面包屑导航组件-->
      <!-- isShowArchived : 布尔值，是否显示当前页面归档组件-->
      <template slot="content-item-breadCrumb">
        <BreadCrumb></BreadCrumb>
      </template>
      <template slot="content-item">
        <!-- 内容插槽 -->
        <article-list>
          <template slot="title"
            ><div class="article-title">
              {{ contentTitle }}
            </div></template
          >
        </article-list>
      </template>
    </base-header-footer>
  </div>
</template>

<script>
import BreadCrumb from "@/components/breadcrumb/BreadCrumb.vue";
import ArticleList from "@/components/articlelist/ArticleList.vue";
import BaseHeaderFooter from "@/components/baseheaderfooter/BaseHeaderFooter.vue";
export default {
  name: "",
  components: {
    BreadCrumb,
    ArticleList,
    BaseHeaderFooter,
  },
  data() {
    return {
      contentTitle: "",
    };
  },
  async asyncData(app) {
    //获取年份标题

    //时间归档
    let pathArr = app.route.path.split("/");
    let activePathArr = [];
    for (let i = 0; i < pathArr.length; i++) {
      pathArr[i] = "/" + pathArr[i];
      if (i == 0) {
        activePathArr.push({ id: i + 1, path: "/", title: "首页" });
      } else if (i == 2) {
        activePathArr.push({
          id: i + 1,
          path: "/date/" + app.route.params.year,
          title: app.route.params.year,
        });
      } else if (i == 3) {
        activePathArr.push({
          id: i + 1,
          path: "/date/" + app.route.params.year + "/" + app.route.params.month,
          title: app.route.params.month,
        });
      }
    }

    app.$cookies.set("activePathArr", activePathArr);

    let contentTitle = "";
    if (app.route.name == "year" || app.route.name=='year-page') {
      contentTitle = "按时间归档：" + app.route.params.year + "年";
    } else if (app.route.name == "month" || app.route.name=='month-page') {
      contentTitle =
        "按时间归档：" +
        app.route.params.year +
        "年" +
        app.route.params.month +
        "月";
    }
    return {
      contentTitle,
    };
  },
};
</script>
<style lang="less" scoped>
</style>